home *** CD-ROM | disk | FTP | other *** search
/ Computer Arts: Pro Software Skills - Photoshop / Computer Arts Pro Software Skills Photoshop.iso / pc / main.swf / scripts / __Packages / mx / video / VideoPlayer.as < prev   
Encoding:
Text File  |  2011-06-06  |  58.1 KB  |  1,861 lines

  1. class mx.video.VideoPlayer extends MovieClip
  2. {
  3.    var _state;
  4.    var _cachedState;
  5.    var _bufferState;
  6.    var _sawPlayStop;
  7.    var _cachedPlayheadTime;
  8.    var _metadata;
  9.    var _startingPlay;
  10.    var _invalidSeekTime;
  11.    var _invalidSeekRecovery;
  12.    var _currentPos;
  13.    var _atEnd;
  14.    var _cmdQueue;
  15.    var _readyDispatched;
  16.    var _autoResizeDone;
  17.    var _lastUpdateTime;
  18.    var _sawSeekNotify;
  19.    var _updateTimeIntervalID;
  20.    var _updateTimeInterval;
  21.    var _updateProgressIntervalID;
  22.    var _updateProgressInterval;
  23.    var _idleTimeoutIntervalID;
  24.    var _idleTimeoutInterval;
  25.    var _autoResizeIntervalID;
  26.    var _rtmpDoStopAtEndIntervalID;
  27.    var _rtmpDoSeekIntervalID;
  28.    var _httpDoSeekIntervalID;
  29.    var _httpDoSeekCount;
  30.    var _finishAutoResizeIntervalID;
  31.    var _delayedBufferingIntervalID;
  32.    var _delayedBufferingInterval;
  33.    var _isLive;
  34.    var _autoSize;
  35.    var _aspectRatio;
  36.    var _autoPlay;
  37.    var _autoRewind;
  38.    var _bufferTime;
  39.    var _volume;
  40.    var _sound;
  41.    var __visible;
  42.    var _hiddenForResize;
  43.    var _hiddenForResizeMetadataDelay;
  44.    var _contentPath;
  45.    var _video;
  46.    var _ncMgr;
  47.    var _ns;
  48.    var _prevVideoWidth;
  49.    var _prevVideoHeight;
  50.    var _streamLength;
  51.    var _videoWidth;
  52.    var _videoHeight;
  53.    var dispatchEvent;
  54.    var _hiddenRewindPlayheadTime;
  55.    var ncMgrClassName;
  56.    var mc;
  57.    static var version = "1.0.2.7";
  58.    static var shortVersion = "1.0.2";
  59.    static var DISCONNECTED = "disconnected";
  60.    static var STOPPED = "stopped";
  61.    static var PLAYING = "playing";
  62.    static var PAUSED = "paused";
  63.    static var BUFFERING = "buffering";
  64.    static var LOADING = "loading";
  65.    static var CONNECTION_ERROR = "connectionError";
  66.    static var REWINDING = "rewinding";
  67.    static var SEEKING = "seeking";
  68.    static var RESIZING = "resizing";
  69.    static var EXEC_QUEUED_CMD = "execQueuedCmd";
  70.    static var BUFFER_EMPTY = "bufferEmpty";
  71.    static var BUFFER_FULL = "bufferFull";
  72.    static var BUFFER_FLUSH = "bufferFlush";
  73.    static var DEFAULT_INCMANAGER = "mx.video.NCManager";
  74.    static var DEFAULT_UPDATE_TIME_INTERVAL = 250;
  75.    static var DEFAULT_UPDATE_PROGRESS_INTERVAL = 250;
  76.    static var DEFAULT_IDLE_TIMEOUT_INTERVAL = 300000;
  77.    static var AUTO_RESIZE_INTERVAL = 100;
  78.    static var AUTO_RESIZE_PLAYHEAD_TIMEOUT = 0.5;
  79.    static var AUTO_RESIZE_METADATA_DELAY_MAX = 5;
  80.    static var FINISH_AUTO_RESIZE_INTERVAL = 250;
  81.    static var RTMP_DO_STOP_AT_END_INTERVAL = 500;
  82.    static var RTMP_DO_SEEK_INTERVAL = 100;
  83.    static var HTTP_DO_SEEK_INTERVAL = 250;
  84.    static var HTTP_DO_SEEK_MAX_COUNT = 4;
  85.    static var CLOSE_NS_INTERVAL = 0.25;
  86.    static var HTTP_DELAYED_BUFFERING_INTERVAL = 100;
  87.    static var PLAY = 0;
  88.    static var LOAD = 1;
  89.    static var PAUSE = 2;
  90.    static var STOP = 3;
  91.    static var SEEK = 4;
  92.    function VideoPlayer()
  93.    {
  94.       super();
  95.       mx.events.EventDispatcher.initialize(this);
  96.       this._state = mx.video.VideoPlayer.DISCONNECTED;
  97.       this._cachedState = this._state;
  98.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  99.       this._sawPlayStop = false;
  100.       this._cachedPlayheadTime = 0;
  101.       this._metadata = null;
  102.       this._startingPlay = false;
  103.       this._invalidSeekTime = false;
  104.       this._invalidSeekRecovery = false;
  105.       this._currentPos = 0;
  106.       this._atEnd = false;
  107.       this._cmdQueue = new Array();
  108.       this._readyDispatched = false;
  109.       this._autoResizeDone = false;
  110.       this._lastUpdateTime = -1;
  111.       this._sawSeekNotify = false;
  112.       this._updateTimeIntervalID = 0;
  113.       this._updateTimeInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_TIME_INTERVAL;
  114.       this._updateProgressIntervalID = 0;
  115.       this._updateProgressInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_PROGRESS_INTERVAL;
  116.       this._idleTimeoutIntervalID = 0;
  117.       this._idleTimeoutInterval = mx.video.VideoPlayer.DEFAULT_IDLE_TIMEOUT_INTERVAL;
  118.       this._autoResizeIntervalID = 0;
  119.       this._rtmpDoStopAtEndIntervalID = 0;
  120.       this._rtmpDoSeekIntervalID = 0;
  121.       this._httpDoSeekIntervalID = 0;
  122.       this._httpDoSeekCount = 0;
  123.       this._finishAutoResizeIntervalID = 0;
  124.       this._delayedBufferingIntervalID = 0;
  125.       this._delayedBufferingInterval = mx.video.VideoPlayer.HTTP_DELAYED_BUFFERING_INTERVAL;
  126.       if(this._isLive == undefined)
  127.       {
  128.          this._isLive = false;
  129.       }
  130.       if(this._autoSize == undefined)
  131.       {
  132.          this._autoSize = false;
  133.       }
  134.       if(this._aspectRatio == undefined)
  135.       {
  136.          this._aspectRatio = true;
  137.       }
  138.       if(this._autoPlay == undefined)
  139.       {
  140.          this._autoPlay = true;
  141.       }
  142.       if(this._autoRewind == undefined)
  143.       {
  144.          this._autoRewind = true;
  145.       }
  146.       if(this._bufferTime == undefined)
  147.       {
  148.          this._bufferTime = 0.1;
  149.       }
  150.       if(this._volume == undefined)
  151.       {
  152.          this._volume = 100;
  153.       }
  154.       this._sound = new Sound(this);
  155.       this._sound.setVolume(this._volume);
  156.       this.__visible = true;
  157.       this._hiddenForResize = false;
  158.       this._hiddenForResizeMetadataDelay = 0;
  159.       this._contentPath = "";
  160.    }
  161.    function setSize(w, h)
  162.    {
  163.       if(w == this._video._width && h == this._video._height || this._autoSize)
  164.       {
  165.          return undefined;
  166.       }
  167.       this._video._width = w;
  168.       this._video._height = h;
  169.       if(this._aspectRatio)
  170.       {
  171.          this.startAutoResize();
  172.       }
  173.    }
  174.    function setScale(xs, ys)
  175.    {
  176.       if(xs == this._video._xscale && ys == this._video._yscale || this._autoSize)
  177.       {
  178.          return undefined;
  179.       }
  180.       this._video._xscale = xs;
  181.       this._video._yscale = ys;
  182.       if(this._aspectRatio)
  183.       {
  184.          this.startAutoResize();
  185.       }
  186.    }
  187.    function play(url, isLive, totalTime)
  188.    {
  189.       if(url != null)
  190.       {
  191.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  192.          {
  193.             this._state = this._cachedState;
  194.          }
  195.          else
  196.          {
  197.             if(!this.stateResponsive && this._state != mx.video.VideoPlayer.CONNECTION_ERROR)
  198.             {
  199.                this.queueCmd(mx.video.VideoPlayer.PLAY,url,isLive,totalTime);
  200.                return undefined;
  201.             }
  202.             this.execQueuedCmds();
  203.          }
  204.          this._autoPlay = true;
  205.          this._load(url,isLive,totalTime);
  206.          return undefined;
  207.       }
  208.       if(!this.isXnOK())
  209.       {
  210.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  211.          {
  212.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  213.          }
  214.          this.flushQueuedCmds();
  215.          this.queueCmd(mx.video.VideoPlayer.PLAY);
  216.          this.setState(mx.video.VideoPlayer.LOADING);
  217.          this._cachedState = mx.video.VideoPlayer.LOADING;
  218.          this._ncMgr.reconnect();
  219.          return undefined;
  220.       }
  221.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  222.       {
  223.          this._state = this._cachedState;
  224.       }
  225.       else
  226.       {
  227.          if(!this.stateResponsive)
  228.          {
  229.             this.queueCmd(mx.video.VideoPlayer.PLAY);
  230.             return undefined;
  231.          }
  232.          this.execQueuedCmds();
  233.       }
  234.       if(this._ns == null)
  235.       {
  236.          this._createStream();
  237.          this._video.attachVideo(this._ns);
  238.          this.attachAudio(this._ns);
  239.       }
  240.       switch(this._state)
  241.       {
  242.          case mx.video.VideoPlayer.BUFFERING:
  243.             if(this._ncMgr.isRTMP())
  244.             {
  245.                this._play(0);
  246.                if(this._atEnd)
  247.                {
  248.                   this._atEnd = false;
  249.                   this._currentPos = 0;
  250.                   this.setState(mx.video.VideoPlayer.REWINDING);
  251.                }
  252.                else if(this._currentPos > 0)
  253.                {
  254.                   this._seek(this._currentPos);
  255.                   this._currentPos = 0;
  256.                }
  257.             }
  258.          case mx.video.VideoPlayer.PLAYING:
  259.             return undefined;
  260.          case mx.video.VideoPlayer.STOPPED:
  261.             if(this._ncMgr.isRTMP())
  262.             {
  263.                if(this._isLive)
  264.                {
  265.                   this._play(-1);
  266.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  267.                }
  268.                else
  269.                {
  270.                   this._play(0);
  271.                   if(this._atEnd)
  272.                   {
  273.                      this._atEnd = false;
  274.                      this._currentPos = 0;
  275.                      this._state = mx.video.VideoPlayer.BUFFERING;
  276.                      this.setState(mx.video.VideoPlayer.REWINDING);
  277.                   }
  278.                   else if(this._currentPos > 0)
  279.                   {
  280.                      this._seek(this._currentPos);
  281.                      this._currentPos = 0;
  282.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  283.                   }
  284.                   else
  285.                   {
  286.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  287.                   }
  288.                }
  289.             }
  290.             else
  291.             {
  292.                this._pause(false);
  293.                if(this._atEnd)
  294.                {
  295.                   this._atEnd = false;
  296.                   this._seek(0);
  297.                   this._state = mx.video.VideoPlayer.BUFFERING;
  298.                   this.setState(mx.video.VideoPlayer.REWINDING);
  299.                }
  300.                else if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  301.                {
  302.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  303.                }
  304.                else
  305.                {
  306.                   this.setState(mx.video.VideoPlayer.PLAYING);
  307.                }
  308.             }
  309.             break;
  310.          case mx.video.VideoPlayer.PAUSED:
  311.             this._pause(false);
  312.             if(!this._ncMgr.isRTMP())
  313.             {
  314.                if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  315.                {
  316.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  317.                }
  318.                else
  319.                {
  320.                   this.setState(mx.video.VideoPlayer.PLAYING);
  321.                }
  322.             }
  323.             else
  324.             {
  325.                this.setState(mx.video.VideoPlayer.BUFFERING);
  326.             }
  327.       }
  328.    }
  329.    function load(url, isLive, totalTime)
  330.    {
  331.       if(url == null)
  332.       {
  333.          throw new Error("null url sent to VideoPlayer.load");
  334.       }
  335.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  336.       {
  337.          this._state = this._cachedState;
  338.       }
  339.       else
  340.       {
  341.          if(!this.stateResponsive && this._state != mx.video.VideoPlayer.CONNECTION_ERROR)
  342.          {
  343.             this.queueCmd(mx.video.VideoPlayer.LOAD,url,isLive,totalTime);
  344.             return undefined;
  345.          }
  346.          this.execQueuedCmds();
  347.       }
  348.       this._autoPlay = false;
  349.       this._load(url,isLive,totalTime);
  350.    }
  351.    function _load(url, isLive, totalTime)
  352.    {
  353.       this._prevVideoWidth = this.videoWidth;
  354.       if(this._prevVideoWidth == undefined)
  355.       {
  356.          this._prevVideoWidth = this._video.width;
  357.          if(this._prevVideoWidth == undefined)
  358.          {
  359.             this._prevVideoWidth = 0;
  360.          }
  361.       }
  362.       this._prevVideoHeight = this.videoHeight;
  363.       if(this._prevVideoHeight == undefined)
  364.       {
  365.          this._prevVideoHeight = this._video.height;
  366.          if(this._prevVideoHeight == undefined)
  367.          {
  368.             this._prevVideoHeight = 0;
  369.          }
  370.       }
  371.       this._autoResizeDone = false;
  372.       this._cachedPlayheadTime = 0;
  373.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  374.       this._sawPlayStop = false;
  375.       this._metadata = null;
  376.       this._startingPlay = false;
  377.       this._invalidSeekTime = false;
  378.       this._invalidSeekRecovery = false;
  379.       this._isLive = isLive != undefined ? isLive : false;
  380.       this._contentPath = url;
  381.       this._currentPos = 0;
  382.       this._streamLength = totalTime;
  383.       this._atEnd = false;
  384.       this._videoWidth = undefined;
  385.       this._videoHeight = undefined;
  386.       this._readyDispatched = false;
  387.       this._lastUpdateTime = -1;
  388.       this._sawSeekNotify = false;
  389.       clearInterval(this._updateTimeIntervalID);
  390.       this._updateTimeIntervalID = 0;
  391.       clearInterval(this._updateProgressIntervalID);
  392.       this._updateProgressIntervalID = 0;
  393.       clearInterval(this._idleTimeoutIntervalID);
  394.       this._idleTimeoutIntervalID = 0;
  395.       clearInterval(this._autoResizeIntervalID);
  396.       this._autoResizeIntervalID = 0;
  397.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  398.       this._rtmpDoStopAtEndIntervalID = 0;
  399.       clearInterval(this._rtmpDoSeekIntervalID);
  400.       this._rtmpDoSeekIntervalID = 0;
  401.       clearInterval(this._httpDoSeekIntervalID);
  402.       this._httpDoSeekIntervalID = 0;
  403.       clearInterval(this._finishAutoResizeIntervalID);
  404.       this._finishAutoResizeIntervalID = 0;
  405.       clearInterval(this._delayedBufferingIntervalID);
  406.       this._delayedBufferingIntervalID = 0;
  407.       this.closeNS(false);
  408.       if(this._ncMgr == null)
  409.       {
  410.          this.createINCManager();
  411.       }
  412.       var _loc2_ = this._ncMgr.connectToURL(this._contentPath);
  413.       this.setState(mx.video.VideoPlayer.LOADING);
  414.       this._cachedState = mx.video.VideoPlayer.LOADING;
  415.       if(_loc2_)
  416.       {
  417.          this._createStream();
  418.          this._setUpStream();
  419.       }
  420.       if(!this._ncMgr.isRTMP())
  421.       {
  422.          clearInterval(this._updateProgressIntervalID);
  423.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  424.       }
  425.    }
  426.    function pause()
  427.    {
  428.       if(!this.isXnOK())
  429.       {
  430.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  431.          {
  432.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  433.          }
  434.          return undefined;
  435.       }
  436.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  437.       {
  438.          this._state = this._cachedState;
  439.       }
  440.       else
  441.       {
  442.          if(!this.stateResponsive)
  443.          {
  444.             this.queueCmd(mx.video.VideoPlayer.PAUSE);
  445.             return undefined;
  446.          }
  447.          this.execQueuedCmds();
  448.       }
  449.       if(this._state == mx.video.VideoPlayer.PAUSED || this._state == mx.video.VideoPlayer.STOPPED || this._ns == null)
  450.       {
  451.          return undefined;
  452.       }
  453.       this._pause(true);
  454.       this.setState(mx.video.VideoPlayer.PAUSED);
  455.    }
  456.    function stop()
  457.    {
  458.       if(!this.isXnOK())
  459.       {
  460.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  461.          {
  462.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  463.          }
  464.          return undefined;
  465.       }
  466.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  467.       {
  468.          this._state = this._cachedState;
  469.       }
  470.       else
  471.       {
  472.          if(!this.stateResponsive)
  473.          {
  474.             this.queueCmd(mx.video.VideoPlayer.STOP);
  475.             return undefined;
  476.          }
  477.          this.execQueuedCmds();
  478.       }
  479.       if(this._state == mx.video.VideoPlayer.STOPPED || this._ns == null)
  480.       {
  481.          return undefined;
  482.       }
  483.       if(this._ncMgr.isRTMP())
  484.       {
  485.          if(this._autoRewind && !this._isLive)
  486.          {
  487.             this._currentPos = 0;
  488.             this._play(0,0);
  489.             this._state = mx.video.VideoPlayer.STOPPED;
  490.             this.setState(mx.video.VideoPlayer.REWINDING);
  491.          }
  492.          else
  493.          {
  494.             this.closeNS(true);
  495.             this.setState(mx.video.VideoPlayer.STOPPED);
  496.          }
  497.       }
  498.       else
  499.       {
  500.          this._pause(true);
  501.          if(this._autoRewind)
  502.          {
  503.             this._seek(0);
  504.             this._state = mx.video.VideoPlayer.STOPPED;
  505.             this.setState(mx.video.VideoPlayer.REWINDING);
  506.          }
  507.          else
  508.          {
  509.             this.setState(mx.video.VideoPlayer.STOPPED);
  510.          }
  511.       }
  512.    }
  513.    function seek(time)
  514.    {
  515.       if(this._invalidSeekTime)
  516.       {
  517.          return undefined;
  518.       }
  519.       if(isNaN(time) || time < 0)
  520.       {
  521.          throw new mx.video.VideoError(mx.video.VideoError.INVALID_SEEK);
  522.       }
  523.       if(!this.isXnOK())
  524.       {
  525.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  526.          {
  527.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  528.          }
  529.          this.flushQueuedCmds();
  530.          this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  531.          this.setState(mx.video.VideoPlayer.LOADING);
  532.          this._cachedState = mx.video.VideoPlayer.LOADING;
  533.          this._ncMgr.reconnect();
  534.          return undefined;
  535.       }
  536.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  537.       {
  538.          this._state = this._cachedState;
  539.       }
  540.       else
  541.       {
  542.          if(!this.stateResponsive)
  543.          {
  544.             this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  545.             return undefined;
  546.          }
  547.          this.execQueuedCmds();
  548.       }
  549.       if(this._ns == null)
  550.       {
  551.          this._createStream();
  552.          this._video.attachVideo(this._ns);
  553.          this.attachAudio(this._ns);
  554.       }
  555.       if(this._atEnd && time < this.playheadTime)
  556.       {
  557.          this._atEnd = false;
  558.       }
  559.       switch(this._state)
  560.       {
  561.          case mx.video.VideoPlayer.PLAYING:
  562.             this._state = mx.video.VideoPlayer.BUFFERING;
  563.          case mx.video.VideoPlayer.BUFFERING:
  564.          case mx.video.VideoPlayer.PAUSED:
  565.             this._seek(time);
  566.             this.setState(mx.video.VideoPlayer.SEEKING);
  567.             break;
  568.          case mx.video.VideoPlayer.STOPPED:
  569.             if(this._ncMgr.isRTMP())
  570.             {
  571.                this._play(0);
  572.                this._pause(true);
  573.             }
  574.             this._seek(time);
  575.             this._state = mx.video.VideoPlayer.PAUSED;
  576.             this.setState(mx.video.VideoPlayer.SEEKING);
  577.       }
  578.    }
  579.    function close()
  580.    {
  581.       this.closeNS(true);
  582.       if(this._ncMgr != null && this._ncMgr.isRTMP())
  583.       {
  584.          this._ncMgr.close();
  585.       }
  586.       this.setState(mx.video.VideoPlayer.DISCONNECTED);
  587.       this.dispatchEvent({type:"close",state:this._state,playheadTime:this.playheadTime});
  588.    }
  589.    function get x()
  590.    {
  591.       return this._x;
  592.    }
  593.    function set x(xpos)
  594.    {
  595.       this._x = xpos;
  596.    }
  597.    function get y()
  598.    {
  599.       return this._y;
  600.    }
  601.    function set y(ypos)
  602.    {
  603.       this._y = ypos;
  604.    }
  605.    function get scaleX()
  606.    {
  607.       return this._video._xscale;
  608.    }
  609.    function set scaleX(xs)
  610.    {
  611.       this.setScale(xs,this.scaleY);
  612.    }
  613.    function get scaleY()
  614.    {
  615.       return this._video._yscale;
  616.    }
  617.    function set scaleY(ys)
  618.    {
  619.       this.setScale(this.scaleX,ys);
  620.    }
  621.    function get width()
  622.    {
  623.       return this._video._width;
  624.    }
  625.    function set width(w)
  626.    {
  627.       this.setSize(w,this._video._height);
  628.    }
  629.    function get height()
  630.    {
  631.       return this._video._height;
  632.    }
  633.    function set height(h)
  634.    {
  635.       this.setSize(this._video._width,h);
  636.    }
  637.    function get videoWidth()
  638.    {
  639.       if(this._readyDispatched)
  640.       {
  641.          this._videoWidth = this._video.width;
  642.       }
  643.       return this._videoWidth;
  644.    }
  645.    function get videoHeight()
  646.    {
  647.       if(this._readyDispatched)
  648.       {
  649.          this._videoHeight = this._video.height;
  650.       }
  651.       return this._videoHeight;
  652.    }
  653.    function get visible()
  654.    {
  655.       if(!this._hiddenForResize)
  656.       {
  657.          this.__visible = this._visible;
  658.       }
  659.       return this.__visible;
  660.    }
  661.    function set visible(v)
  662.    {
  663.       this.__visible = v;
  664.       if(!this._hiddenForResize)
  665.       {
  666.          this._visible = this.__visible;
  667.       }
  668.    }
  669.    function get autoSize()
  670.    {
  671.       return this._autoSize;
  672.    }
  673.    function set autoSize(flag)
  674.    {
  675.       if(this._autoSize != flag)
  676.       {
  677.          this._autoSize = flag;
  678.          if(this._autoSize)
  679.          {
  680.             this.startAutoResize();
  681.          }
  682.       }
  683.    }
  684.    function get maintainAspectRatio()
  685.    {
  686.       return this._aspectRatio;
  687.    }
  688.    function set maintainAspectRatio(flag)
  689.    {
  690.       if(this._aspectRatio != flag)
  691.       {
  692.          this._aspectRatio = flag;
  693.          if(this._aspectRatio && !this._autoSize)
  694.          {
  695.             this.startAutoResize();
  696.          }
  697.       }
  698.    }
  699.    function get autoRewind()
  700.    {
  701.       return this._autoRewind;
  702.    }
  703.    function set autoRewind(flag)
  704.    {
  705.       this._autoRewind = flag;
  706.    }
  707.    function get playheadTime()
  708.    {
  709.       var _loc2_ = this._ns != null ? this._ns.time : this._currentPos;
  710.       if(this._metadata.audiodelay != undefined)
  711.       {
  712.          _loc2_ -= this._metadata.audiodelay;
  713.          if(_loc2_ < 0)
  714.          {
  715.             _loc2_ = 0;
  716.          }
  717.       }
  718.       return _loc2_;
  719.    }
  720.    function set playheadTime(position)
  721.    {
  722.       this.seek(position);
  723.    }
  724.    function get url()
  725.    {
  726.       return this._contentPath;
  727.    }
  728.    function get volume()
  729.    {
  730.       return this._volume;
  731.    }
  732.    function set volume(aVol)
  733.    {
  734.       this._volume = aVol;
  735.       if(!this._hiddenForResize)
  736.       {
  737.          this._sound.setVolume(this._volume);
  738.       }
  739.    }
  740.    function get transform()
  741.    {
  742.       return this._sound.getTransform();
  743.    }
  744.    function set transform(s)
  745.    {
  746.       this._sound.setTransform(s);
  747.    }
  748.    function get isRTMP()
  749.    {
  750.       if(this._ncMgr == null)
  751.       {
  752.          return undefined;
  753.       }
  754.       return this._ncMgr.isRTMP();
  755.    }
  756.    function get isLive()
  757.    {
  758.       return this._isLive;
  759.    }
  760.    function get state()
  761.    {
  762.       return this._state;
  763.    }
  764.    function get stateResponsive()
  765.    {
  766.       switch(this._state)
  767.       {
  768.          case mx.video.VideoPlayer.DISCONNECTED:
  769.          case mx.video.VideoPlayer.STOPPED:
  770.          case mx.video.VideoPlayer.PLAYING:
  771.          case mx.video.VideoPlayer.PAUSED:
  772.          case mx.video.VideoPlayer.BUFFERING:
  773.             return true;
  774.          default:
  775.             return false;
  776.       }
  777.    }
  778.    function get bytesLoaded()
  779.    {
  780.       if(this._ns == null || this._ncMgr.isRTMP())
  781.       {
  782.          return -1;
  783.       }
  784.       return this._ns.bytesLoaded;
  785.    }
  786.    function get bytesTotal()
  787.    {
  788.       if(this._ns == null || this._ncMgr.isRTMP())
  789.       {
  790.          return -1;
  791.       }
  792.       return this._ns.bytesTotal;
  793.    }
  794.    function get totalTime()
  795.    {
  796.       return this._streamLength;
  797.    }
  798.    function get bufferTime()
  799.    {
  800.       return this._bufferTime;
  801.    }
  802.    function set bufferTime(aTime)
  803.    {
  804.       this._bufferTime = aTime;
  805.       if(this._ns != null)
  806.       {
  807.          this._ns.setBufferTime(this._bufferTime);
  808.       }
  809.    }
  810.    function get idleTimeout()
  811.    {
  812.       return this._idleTimeoutInterval;
  813.    }
  814.    function set idleTimeout(aTime)
  815.    {
  816.       this._idleTimeoutInterval = aTime;
  817.       if(this._idleTimeoutIntervalID > 0)
  818.       {
  819.          clearInterval(this._idleTimeoutIntervalID);
  820.          this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  821.       }
  822.    }
  823.    function get playheadUpdateInterval()
  824.    {
  825.       return this._updateTimeInterval;
  826.    }
  827.    function set playheadUpdateInterval(aTime)
  828.    {
  829.       this._updateTimeInterval = aTime;
  830.       if(this._updateTimeIntervalID > 0)
  831.       {
  832.          clearInterval(this._updateTimeIntervalID);
  833.          this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  834.       }
  835.    }
  836.    function get progressInterval()
  837.    {
  838.       return this._updateProgressInterval;
  839.    }
  840.    function set progressInterval(aTime)
  841.    {
  842.       this._updateProgressInterval = aTime;
  843.       if(this._updateProgressIntervalID > 0)
  844.       {
  845.          clearInterval(this._updateProgressIntervalID);
  846.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  847.       }
  848.    }
  849.    function get ncMgr()
  850.    {
  851.       if(this._ncMgr == null)
  852.       {
  853.          this.createINCManager();
  854.       }
  855.       return this._ncMgr;
  856.    }
  857.    function get metadata()
  858.    {
  859.       return this._metadata;
  860.    }
  861.    function doUpdateTime()
  862.    {
  863.       var _loc2_ = this.playheadTime;
  864.       switch(this._state)
  865.       {
  866.          case mx.video.VideoPlayer.STOPPED:
  867.          case mx.video.VideoPlayer.PAUSED:
  868.          case mx.video.VideoPlayer.DISCONNECTED:
  869.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  870.             clearInterval(this._updateTimeIntervalID);
  871.             this._updateTimeIntervalID = 0;
  872.       }
  873.       if(this._lastUpdateTime != _loc2_)
  874.       {
  875.          this.dispatchEvent({type:"playheadUpdate",state:this._state,playheadTime:_loc2_});
  876.          this._lastUpdateTime = _loc2_;
  877.       }
  878.    }
  879.    function doUpdateProgress()
  880.    {
  881.       if(this._ns == null)
  882.       {
  883.          return undefined;
  884.       }
  885.       if(this._ns.bytesTotal >= 0 && this._ns.bytesTotal >= 0)
  886.       {
  887.          this.dispatchEvent({type:"progress",bytesLoaded:this._ns.bytesLoaded,bytesTotal:this._ns.bytesTotal});
  888.       }
  889.       if(this._state == mx.video.VideoPlayer.DISCONNECTED || this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ns.bytesLoaded == this._ns.bytesTotal)
  890.       {
  891.          clearInterval(this._updateProgressIntervalID);
  892.          this._updateProgressIntervalID = 0;
  893.       }
  894.    }
  895.    function rtmpOnStatus(info)
  896.    {
  897.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  898.       {
  899.          return undefined;
  900.       }
  901.       switch(info.code)
  902.       {
  903.          case "NetStream.Play.Stop":
  904.             if(this._startingPlay)
  905.             {
  906.                return undefined;
  907.             }
  908.             switch(this._state)
  909.             {
  910.                case mx.video.VideoPlayer.RESIZING:
  911.                   if(this._hiddenForResize)
  912.                   {
  913.                      this.finishAutoResize();
  914.                   }
  915.                   break;
  916.                case mx.video.VideoPlayer.LOADING:
  917.                case mx.video.VideoPlayer.STOPPED:
  918.                case mx.video.VideoPlayer.PAUSED:
  919.                   break;
  920.                default:
  921.                   this._sawPlayStop = true;
  922.             }
  923.             break;
  924.          case "NetStream.Buffer.Empty":
  925.             var _loc0_ = null;
  926.             if((_loc0_ = this._bufferState) === mx.video.VideoPlayer.BUFFER_FULL)
  927.             {
  928.                if(this._sawPlayStop)
  929.                {
  930.                   this.rtmpDoStopAtEnd(true);
  931.                }
  932.                else if(this._state == mx.video.VideoPlayer.PLAYING)
  933.                {
  934.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  935.                }
  936.             }
  937.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  938.             this._sawPlayStop = false;
  939.             break;
  940.          case "NetStream.Buffer.Flush":
  941.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  942.             {
  943.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  944.                this._sawPlayStop = false;
  945.                this.setStateFromCachedState();
  946.                this.doUpdateTime();
  947.             }
  948.             if(this._sawPlayStop && (this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY || this._bufferTime <= 0.1 && this._ns.bufferLength <= 0.1))
  949.             {
  950.                this._cachedPlayheadTime = this.playheadTime;
  951.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  952.                this._rtmpDoStopAtEndIntervalID = setInterval(this,"rtmpDoStopAtEnd",mx.video.VideoPlayer.RTMP_DO_STOP_AT_END_INTERVAL);
  953.             }
  954.             if((_loc0_ = this._bufferState) !== mx.video.VideoPlayer.BUFFER_EMPTY)
  955.             {
  956.                if(this._state == mx.video.VideoPlayer.BUFFERING)
  957.                {
  958.                   this.setStateFromCachedState();
  959.                }
  960.             }
  961.             else
  962.             {
  963.                if(!this._hiddenForResize)
  964.                {
  965.                   if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  966.                   {
  967.                      this.setState(mx.video.VideoPlayer.PLAYING);
  968.                   }
  969.                   else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  970.                   {
  971.                      this._cachedState = mx.video.VideoPlayer.PLAYING;
  972.                   }
  973.                }
  974.                this._bufferState = mx.video.VideoPlayer.BUFFER_FLUSH;
  975.             }
  976.             break;
  977.          case "NetStream.Buffer.Full":
  978.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  979.             {
  980.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  981.                this._sawPlayStop = false;
  982.                this.setStateFromCachedState();
  983.                this.doUpdateTime();
  984.             }
  985.             switch(this._bufferState)
  986.             {
  987.                case mx.video.VideoPlayer.BUFFER_EMPTY:
  988.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  989.                   if(!this._hiddenForResize)
  990.                   {
  991.                      if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  992.                      {
  993.                         this.setState(mx.video.VideoPlayer.PLAYING);
  994.                      }
  995.                      else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  996.                      {
  997.                         this._cachedState = mx.video.VideoPlayer.PLAYING;
  998.                      }
  999.                      if(this._rtmpDoStopAtEndIntervalID != 0)
  1000.                      {
  1001.                         this._sawPlayStop = true;
  1002.                         clearInterval(this._rtmpDoStopAtEndIntervalID);
  1003.                         this._rtmpDoStopAtEndIntervalID = 0;
  1004.                      }
  1005.                   }
  1006.                   break;
  1007.                case mx.video.VideoPlayer.BUFFER_FLUSH:
  1008.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  1009.                   if(this._rtmpDoStopAtEndIntervalID != 0)
  1010.                   {
  1011.                      this._sawPlayStop = true;
  1012.                      clearInterval(this._rtmpDoStopAtEndIntervalID);
  1013.                      this._rtmpDoStopAtEndIntervalID = 0;
  1014.                   }
  1015.             }
  1016.             if(this._state == mx.video.VideoPlayer.BUFFERING)
  1017.             {
  1018.                this.setStateFromCachedState();
  1019.             }
  1020.             break;
  1021.          case "NetStream.Pause.Notify":
  1022.             if(this._state == mx.video.VideoPlayer.RESIZING && this._hiddenForResize)
  1023.             {
  1024.                this.finishAutoResize();
  1025.             }
  1026.             break;
  1027.          case "NetStream.Unpause.Notify":
  1028.             if(this._state == mx.video.VideoPlayer.PAUSED)
  1029.             {
  1030.                this._state = mx.video.VideoPlayer.PLAYING;
  1031.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1032.             }
  1033.             else
  1034.             {
  1035.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  1036.             }
  1037.             break;
  1038.          case "NetStream.Play.Start":
  1039.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1040.             this._rtmpDoStopAtEndIntervalID = 0;
  1041.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1042.             this._sawPlayStop = false;
  1043.             if(this._startingPlay)
  1044.             {
  1045.                this._startingPlay = false;
  1046.                this._cachedPlayheadTime = this.playheadTime;
  1047.             }
  1048.             else if(this._state == mx.video.VideoPlayer.PLAYING)
  1049.             {
  1050.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1051.             }
  1052.             break;
  1053.          case "NetStream.Play.Reset":
  1054.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1055.             this._rtmpDoStopAtEndIntervalID = 0;
  1056.             if(this._state == mx.video.VideoPlayer.REWINDING)
  1057.             {
  1058.                clearInterval(this._rtmpDoSeekIntervalID);
  1059.                this._rtmpDoSeekIntervalID = 0;
  1060.                if(this.playheadTime == 0 || this.playheadTime < this._cachedPlayheadTime)
  1061.                {
  1062.                   this.setStateFromCachedState();
  1063.                }
  1064.                else
  1065.                {
  1066.                   this._cachedPlayheadTime = this.playheadTime;
  1067.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1068.                }
  1069.             }
  1070.             break;
  1071.          case "NetStream.Seek.Notify":
  1072.             if(this.playheadTime != this._cachedPlayheadTime)
  1073.             {
  1074.                this.setStateFromCachedState();
  1075.                this.doUpdateTime();
  1076.             }
  1077.             else
  1078.             {
  1079.                this._sawSeekNotify = true;
  1080.                if(this._rtmpDoSeekIntervalID == 0)
  1081.                {
  1082.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1083.                }
  1084.             }
  1085.             break;
  1086.          case "Netstream.Play.UnpublishNotify":
  1087.          case "Netstream.Play.PublishNotify":
  1088.             break;
  1089.          case "NetStream.Play.StreamNotFound":
  1090.             if(!this._ncMgr.connectAgain())
  1091.             {
  1092.                this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1093.             }
  1094.             break;
  1095.          case "NetStream.Play.Failed":
  1096.          case "NetStream.Failed":
  1097.          case "NetStream.Play.FileStructureInvalid":
  1098.          case "NetStream.Play.NoSupportedTrackFound":
  1099.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1100.       }
  1101.    }
  1102.    function httpOnStatus(info)
  1103.    {
  1104.       switch(info.code)
  1105.       {
  1106.          case "NetStream.Play.Stop":
  1107.             clearInterval(this._delayedBufferingIntervalID);
  1108.             this._delayedBufferingIntervalID = 0;
  1109.             if(this._invalidSeekTime)
  1110.             {
  1111.                this._invalidSeekTime = false;
  1112.                this._invalidSeekRecovery = true;
  1113.                this.setState(this._cachedState);
  1114.                this.seek(this.playheadTime);
  1115.             }
  1116.             else
  1117.             {
  1118.                switch(this._state)
  1119.                {
  1120.                   case mx.video.VideoPlayer.SEEKING:
  1121.                      this.httpDoSeek();
  1122.                   case mx.video.VideoPlayer.PLAYING:
  1123.                   case mx.video.VideoPlayer.BUFFERING:
  1124.                      this.httpDoStopAtEnd();
  1125.                }
  1126.             }
  1127.             break;
  1128.          case "NetStream.Seek.InvalidTime":
  1129.             if(this._invalidSeekRecovery)
  1130.             {
  1131.                this._invalidSeekTime = false;
  1132.                this._invalidSeekRecovery = false;
  1133.                this.setState(this._cachedState);
  1134.                this.seek(0);
  1135.             }
  1136.             else
  1137.             {
  1138.                this._invalidSeekTime = true;
  1139.             }
  1140.             break;
  1141.          case "NetStream.Buffer.Empty":
  1142.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1143.             if(this._state == mx.video.VideoPlayer.PLAYING)
  1144.             {
  1145.                clearInterval(this._delayedBufferingIntervalID);
  1146.                this._delayedBufferingIntervalID = setInterval(this,"doDelayedBuffering",this._delayedBufferingInterval);
  1147.             }
  1148.             break;
  1149.          case "NetStream.Buffer.Full":
  1150.          case "NetStream.Buffer.Flush":
  1151.             clearInterval(this._delayedBufferingIntervalID);
  1152.             this._delayedBufferingIntervalID = 0;
  1153.             this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  1154.             if(!this._hiddenForResize)
  1155.             {
  1156.                if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  1157.                {
  1158.                   this.setState(mx.video.VideoPlayer.PLAYING);
  1159.                }
  1160.                else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  1161.                {
  1162.                   this._cachedState = mx.video.VideoPlayer.PLAYING;
  1163.                }
  1164.             }
  1165.             break;
  1166.          case "NetStream.Seek.Notify":
  1167.             this._invalidSeekRecovery = false;
  1168.             switch(this._state)
  1169.             {
  1170.                case mx.video.VideoPlayer.SEEKING:
  1171.                case mx.video.VideoPlayer.REWINDING:
  1172.                   if(this._httpDoSeekIntervalID == 0)
  1173.                   {
  1174.                      this._httpDoSeekCount = 0;
  1175.                      this._httpDoSeekIntervalID = setInterval(this,"httpDoSeek",mx.video.VideoPlayer.HTTP_DO_SEEK_INTERVAL);
  1176.                   }
  1177.             }
  1178.             break;
  1179.          case "NetStream.Play.StreamNotFound":
  1180.          case "NetStream.Play.FileStructureInvalid":
  1181.          case "NetStream.Play.NoSupportedTrackFound":
  1182.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1183.       }
  1184.    }
  1185.    function ncConnected()
  1186.    {
  1187.       if(this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  1188.       {
  1189.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1190.       }
  1191.       else if(this._ns == null)
  1192.       {
  1193.          this._createStream();
  1194.          this._setUpStream();
  1195.       }
  1196.    }
  1197.    function ncReconnected()
  1198.    {
  1199.       if(this._ncMgr == null || this._ncMgr.getNetConnection() == null)
  1200.       {
  1201.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1202.       }
  1203.       else
  1204.       {
  1205.          this._ns = null;
  1206.          this._state = mx.video.VideoPlayer.STOPPED;
  1207.          this.execQueuedCmds();
  1208.       }
  1209.    }
  1210.    function onMetaData(info)
  1211.    {
  1212.       if(this._metadata != null)
  1213.       {
  1214.          return undefined;
  1215.       }
  1216.       this._metadata = info;
  1217.       if(this._streamLength == null || this._streamLength <= 0)
  1218.       {
  1219.          this._streamLength = info.duration;
  1220.       }
  1221.       if(isNaN(this._videoWidth) || this._videoWidth <= 0)
  1222.       {
  1223.          this._videoWidth = info.width;
  1224.       }
  1225.       if(isNaN(this._videoHeight) || this._videoHeight <= 0)
  1226.       {
  1227.          this._videoHeight = info.height;
  1228.       }
  1229.       this.dispatchEvent({type:"metadataReceived",info:info});
  1230.    }
  1231.    function onCuePoint(info)
  1232.    {
  1233.       if(!this._hiddenForResize || !isNaN(this._hiddenRewindPlayheadTime) && this.playheadTime < this._hiddenRewindPlayheadTime)
  1234.       {
  1235.          this.dispatchEvent({type:"cuePoint",info:info});
  1236.       }
  1237.    }
  1238.    function setState(s)
  1239.    {
  1240.       if(s == this._state)
  1241.       {
  1242.          return undefined;
  1243.       }
  1244.       this._hiddenRewindPlayheadTime = undefined;
  1245.       this._cachedState = this._state;
  1246.       this._cachedPlayheadTime = this.playheadTime;
  1247.       this._state = s;
  1248.       var _loc2_ = this._state;
  1249.       this.dispatchEvent({type:"stateChange",state:_loc2_,playheadTime:this.playheadTime});
  1250.       if(!this._readyDispatched)
  1251.       {
  1252.          switch(_loc2_)
  1253.          {
  1254.             case mx.video.VideoPlayer.STOPPED:
  1255.             case mx.video.VideoPlayer.PLAYING:
  1256.             case mx.video.VideoPlayer.PAUSED:
  1257.             case mx.video.VideoPlayer.BUFFERING:
  1258.                this._readyDispatched = true;
  1259.                this.dispatchEvent({type:"ready",state:_loc2_,playheadTime:this.playheadTime});
  1260.          }
  1261.       }
  1262.       var _loc0_ = null;
  1263.       if((_loc0_ = this._cachedState) === mx.video.VideoPlayer.REWINDING)
  1264.       {
  1265.          this.dispatchEvent({type:"rewind",state:_loc2_,playheadTime:this.playheadTime});
  1266.          if(this._ncMgr.isRTMP() && _loc2_ == mx.video.VideoPlayer.STOPPED)
  1267.          {
  1268.             this.closeNS();
  1269.          }
  1270.       }
  1271.       switch(_loc2_)
  1272.       {
  1273.          case mx.video.VideoPlayer.STOPPED:
  1274.          case mx.video.VideoPlayer.PAUSED:
  1275.             if(this._ncMgr.isRTMP() && this._idleTimeoutIntervalID == 0)
  1276.             {
  1277.                this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  1278.             }
  1279.             break;
  1280.          case mx.video.VideoPlayer.SEEKING:
  1281.          case mx.video.VideoPlayer.REWINDING:
  1282.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1283.             this._sawPlayStop = false;
  1284.          case mx.video.VideoPlayer.PLAYING:
  1285.          case mx.video.VideoPlayer.BUFFERING:
  1286.             if(this._updateTimeIntervalID == 0)
  1287.             {
  1288.                this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  1289.             }
  1290.          case mx.video.VideoPlayer.LOADING:
  1291.          case mx.video.VideoPlayer.RESIZING:
  1292.             clearInterval(this._idleTimeoutIntervalID);
  1293.             this._idleTimeoutIntervalID = 0;
  1294.       }
  1295.       this.execQueuedCmds();
  1296.    }
  1297.    function setStateFromCachedState()
  1298.    {
  1299.       switch(this._cachedState)
  1300.       {
  1301.          case mx.video.VideoPlayer.PLAYING:
  1302.          case mx.video.VideoPlayer.PAUSED:
  1303.             this.setState(this._cachedState);
  1304.             break;
  1305.          case mx.video.VideoPlayer.BUFFERING:
  1306.             if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  1307.             {
  1308.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1309.             }
  1310.             else
  1311.             {
  1312.                this.setState(this._cachedState);
  1313.             }
  1314.             break;
  1315.          default:
  1316.             this.setState(mx.video.VideoPlayer.STOPPED);
  1317.       }
  1318.    }
  1319.    function createINCManager()
  1320.    {
  1321.       if(this.ncMgrClassName == null)
  1322.       {
  1323.          this.ncMgrClassName = mx.video.VideoPlayer.DEFAULT_INCMANAGER;
  1324.       }
  1325.       var ncMgrConstructor = eval(this.ncMgrClassName);
  1326.       this._ncMgr = new ncMgrConstructor();
  1327.       this._ncMgr.setVideoPlayer(this);
  1328.    }
  1329.    function rtmpDoStopAtEnd(force)
  1330.    {
  1331.       if(this._rtmpDoStopAtEndIntervalID > 0)
  1332.       {
  1333.          switch(this._state)
  1334.          {
  1335.             case mx.video.VideoPlayer.DISCONNECTED:
  1336.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1337.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1338.                this._rtmpDoStopAtEndIntervalID = 0;
  1339.                return undefined;
  1340.             default:
  1341.                if(!(force || this._cachedPlayheadTime == this.playheadTime))
  1342.                {
  1343.                   this._cachedPlayheadTime = this.playheadTime;
  1344.                   return undefined;
  1345.                }
  1346.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1347.                this._rtmpDoStopAtEndIntervalID = 0;
  1348.          }
  1349.       }
  1350.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1351.       this._sawPlayStop = false;
  1352.       this._atEnd = true;
  1353.       this.setState(mx.video.VideoPlayer.STOPPED);
  1354.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1355.       {
  1356.          return undefined;
  1357.       }
  1358.       this.doUpdateTime();
  1359.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1360.       {
  1361.          return undefined;
  1362.       }
  1363.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.playheadTime});
  1364.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1365.       {
  1366.          return undefined;
  1367.       }
  1368.       if(this._autoRewind && !this._isLive && this.playheadTime != 0)
  1369.       {
  1370.          this._atEnd = false;
  1371.          this._currentPos = 0;
  1372.          this._play(0,0);
  1373.          this.setState(mx.video.VideoPlayer.REWINDING);
  1374.       }
  1375.       else
  1376.       {
  1377.          this.closeNS();
  1378.       }
  1379.    }
  1380.    function rtmpDoSeek()
  1381.    {
  1382.       if(this._state != mx.video.VideoPlayer.REWINDING && this._state != mx.video.VideoPlayer.SEEKING)
  1383.       {
  1384.          clearInterval(this._rtmpDoSeekIntervalID);
  1385.          this._rtmpDoSeekIntervalID = 0;
  1386.          this._sawSeekNotify = false;
  1387.       }
  1388.       else if(this.playheadTime != this._cachedPlayheadTime)
  1389.       {
  1390.          clearInterval(this._rtmpDoSeekIntervalID);
  1391.          this._rtmpDoSeekIntervalID = 0;
  1392.          this._sawSeekNotify = false;
  1393.          this.setStateFromCachedState();
  1394.          this.doUpdateTime();
  1395.       }
  1396.    }
  1397.    function httpDoStopAtEnd()
  1398.    {
  1399.       this._atEnd = true;
  1400.       if(this._streamLength == null || this._streamLength <= 0)
  1401.       {
  1402.          this._streamLength = this._ns.time;
  1403.       }
  1404.       this._pause(true);
  1405.       this.setState(mx.video.VideoPlayer.STOPPED);
  1406.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1407.       {
  1408.          return undefined;
  1409.       }
  1410.       this.doUpdateTime();
  1411.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1412.       {
  1413.          return undefined;
  1414.       }
  1415.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.playheadTime});
  1416.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1417.       {
  1418.          return undefined;
  1419.       }
  1420.       if(this._autoRewind)
  1421.       {
  1422.          this._atEnd = false;
  1423.          this._pause(true);
  1424.          this._seek(0);
  1425.          this.setState(mx.video.VideoPlayer.REWINDING);
  1426.       }
  1427.    }
  1428.    function httpDoSeek()
  1429.    {
  1430.       var _loc2_ = this._state == mx.video.VideoPlayer.REWINDING || this._state == mx.video.VideoPlayer.SEEKING;
  1431.       if(_loc2_ && this._httpDoSeekCount < mx.video.VideoPlayer.HTTP_DO_SEEK_MAX_COUNT && (this._cachedPlayheadTime == this.playheadTime || this._invalidSeekTime))
  1432.       {
  1433.          this._httpDoSeekCount = this._httpDoSeekCount + 1;
  1434.          return undefined;
  1435.       }
  1436.       this._httpDoSeekCount = 0;
  1437.       clearInterval(this._httpDoSeekIntervalID);
  1438.       this._httpDoSeekIntervalID = 0;
  1439.       if(!_loc2_)
  1440.       {
  1441.          return undefined;
  1442.       }
  1443.       this.setStateFromCachedState();
  1444.       if(this._invalidSeekTime)
  1445.       {
  1446.          this._invalidSeekTime = false;
  1447.          this._invalidSeekRecovery = true;
  1448.          this.seek(this.playheadTime);
  1449.       }
  1450.       else
  1451.       {
  1452.          this.doUpdateTime();
  1453.       }
  1454.    }
  1455.    function closeNS(updateCurrentPos)
  1456.    {
  1457.       if(this._ns != null && this._ns != undefined)
  1458.       {
  1459.          if(updateCurrentPos)
  1460.          {
  1461.             clearInterval(this._updateTimeIntervalID);
  1462.             this._updateTimeIntervalID = 0;
  1463.             this.doUpdateTime();
  1464.             this._currentPos = this._ns.time;
  1465.          }
  1466.          delete this._ns.onStatus;
  1467.          this._ns.onStatus = null;
  1468.          this._ns.close();
  1469.          this._ns = null;
  1470.       }
  1471.    }
  1472.    function doDelayedBuffering()
  1473.    {
  1474.       switch(this._state)
  1475.       {
  1476.          case mx.video.VideoPlayer.LOADING:
  1477.          case mx.video.VideoPlayer.RESIZING:
  1478.             break;
  1479.          case mx.video.VideoPlayer.PLAYING:
  1480.             clearInterval(this._delayedBufferingIntervalID);
  1481.             this._delayedBufferingIntervalID = 0;
  1482.             this.setState(mx.video.VideoPlayer.BUFFERING);
  1483.             break;
  1484.          default:
  1485.             clearInterval(this._delayedBufferingIntervalID);
  1486.             this._delayedBufferingIntervalID = 0;
  1487.       }
  1488.    }
  1489.    function _pause(doPause)
  1490.    {
  1491.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1492.       this._rtmpDoStopAtEndIntervalID = 0;
  1493.       this._ns.pause(doPause);
  1494.    }
  1495.    function _play()
  1496.    {
  1497.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1498.       this._rtmpDoStopAtEndIntervalID = 0;
  1499.       this._startingPlay = true;
  1500.       switch(arguments.length)
  1501.       {
  1502.          case 0:
  1503.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? 0 : -1,-1);
  1504.             break;
  1505.          case 1:
  1506.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,-1);
  1507.             break;
  1508.          case 2:
  1509.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,arguments[1]);
  1510.             break;
  1511.          default:
  1512.             throw new Error("bad args to _play");
  1513.       }
  1514.    }
  1515.    function _seek(time)
  1516.    {
  1517.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1518.       this._rtmpDoStopAtEndIntervalID = 0;
  1519.       if(this._metadata.audiodelay != undefined && time + this._metadata.audiodelay < this._streamLength)
  1520.       {
  1521.          time += this._metadata.audiodelay;
  1522.       }
  1523.       this._ns.seek(time);
  1524.       this._invalidSeekTime = false;
  1525.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1526.       this._sawPlayStop = false;
  1527.       this._sawSeekNotify = false;
  1528.    }
  1529.    function isXnOK()
  1530.    {
  1531.       if(this._state == mx.video.VideoPlayer.LOADING)
  1532.       {
  1533.          return true;
  1534.       }
  1535.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  1536.       {
  1537.          return false;
  1538.       }
  1539.       if(this._state != mx.video.VideoPlayer.DISCONNECTED)
  1540.       {
  1541.          if(this._ncMgr == null || this._ncMgr.getNetConnection() == null || !this._ncMgr.getNetConnection().isConnected)
  1542.          {
  1543.             this.setState(mx.video.VideoPlayer.DISCONNECTED);
  1544.             return false;
  1545.          }
  1546.          return true;
  1547.       }
  1548.       return false;
  1549.    }
  1550.    function startAutoResize()
  1551.    {
  1552.       switch(this._state)
  1553.       {
  1554.          case mx.video.VideoPlayer.DISCONNECTED:
  1555.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  1556.             return undefined;
  1557.          default:
  1558.             this._autoResizeDone = false;
  1559.             if(this.stateResponsive && this._videoWidth != undefined && this._videoHeight != undefined)
  1560.             {
  1561.                this.doAutoResize();
  1562.             }
  1563.             else
  1564.             {
  1565.                clearInterval(this._autoResizeIntervalID);
  1566.                this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1567.             }
  1568.       }
  1569.    }
  1570.    function doAutoResize()
  1571.    {
  1572.       if(this._autoResizeIntervalID > 0)
  1573.       {
  1574.          switch(this._state)
  1575.          {
  1576.             case mx.video.VideoPlayer.RESIZING:
  1577.             case mx.video.VideoPlayer.LOADING:
  1578.                break;
  1579.             case mx.video.VideoPlayer.DISCONNECTED:
  1580.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1581.                clearInterval(this._autoResizeIntervalID);
  1582.                this._autoResizeIntervalID = 0;
  1583.                return undefined;
  1584.             default:
  1585.                if(!this.stateResponsive)
  1586.                {
  1587.                   return undefined;
  1588.                }
  1589.                break;
  1590.          }
  1591.          if(!(this._video.width != this._prevVideoWidth || this._video.height != this._prevVideoHeight || this._bufferState == mx.video.VideoPlayer.BUFFER_FULL || this._bufferState == mx.video.VideoPlayer.BUFFER_FLUSH || this._ns.time > mx.video.VideoPlayer.AUTO_RESIZE_PLAYHEAD_TIMEOUT))
  1592.          {
  1593.             return undefined;
  1594.          }
  1595.          if(this._hiddenForResize && this._metadata == null && this._hiddenForResizeMetadataDelay < mx.video.VideoPlayer.AUTO_RESIZE_METADATA_DELAY_MAX)
  1596.          {
  1597.             this._hiddenForResizeMetadataDelay = this._hiddenForResizeMetadataDelay + 1;
  1598.             return undefined;
  1599.          }
  1600.          this._videoWidth = this._video.width;
  1601.          this._videoHeight = this._video.height;
  1602.          clearInterval(this._autoResizeIntervalID);
  1603.          this._autoResizeIntervalID = 0;
  1604.       }
  1605.       if(!this._autoSize && !this._aspectRatio || this._autoResizeDone)
  1606.       {
  1607.          this.setState(this._cachedState);
  1608.          return undefined;
  1609.       }
  1610.       this._autoResizeDone = true;
  1611.       if(this._autoSize)
  1612.       {
  1613.          this._video._width = this._videoWidth;
  1614.          this._video._height = this._videoHeight;
  1615.       }
  1616.       else if(this._aspectRatio)
  1617.       {
  1618.          var _loc3_ = this._videoWidth * this.height / this._videoHeight;
  1619.          var _loc2_ = this._videoHeight * this.width / this._videoWidth;
  1620.          if(_loc2_ < this.height)
  1621.          {
  1622.             this._video._height = _loc2_;
  1623.          }
  1624.          else if(_loc3_ < this.width)
  1625.          {
  1626.             this._video._width = _loc3_;
  1627.          }
  1628.       }
  1629.       if(this._hiddenForResize)
  1630.       {
  1631.          this._hiddenRewindPlayheadTime = this.playheadTime;
  1632.          if(this._state == mx.video.VideoPlayer.LOADING)
  1633.          {
  1634.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1635.          }
  1636.          if(!this._ncMgr.isRTMP())
  1637.          {
  1638.             this._pause(true);
  1639.             this._seek(0);
  1640.             clearInterval(this._finishAutoResizeIntervalID);
  1641.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1642.          }
  1643.          else if(!this._isLive)
  1644.          {
  1645.             this._currentPos = 0;
  1646.             this._play(0,0);
  1647.             this.setState(mx.video.VideoPlayer.RESIZING);
  1648.          }
  1649.          else if(this._autoPlay)
  1650.          {
  1651.             clearInterval(this._finishAutoResizeIntervalID);
  1652.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1653.          }
  1654.          else
  1655.          {
  1656.             this.finishAutoResize();
  1657.          }
  1658.       }
  1659.       else
  1660.       {
  1661.          this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1662.       }
  1663.    }
  1664.    function finishAutoResize()
  1665.    {
  1666.       clearInterval(this._finishAutoResizeIntervalID);
  1667.       this._finishAutoResizeIntervalID = 0;
  1668.       if(this.stateResponsive)
  1669.       {
  1670.          return undefined;
  1671.       }
  1672.       this._visible = this.__visible;
  1673.       this._sound.setVolume(this._volume);
  1674.       this._hiddenForResize = false;
  1675.       this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1676.       if(this._autoPlay)
  1677.       {
  1678.          if(this._ncMgr.isRTMP())
  1679.          {
  1680.             if(!this._isLive)
  1681.             {
  1682.                this._currentPos = 0;
  1683.                this._play(0);
  1684.             }
  1685.             if(this._state == mx.video.VideoPlayer.RESIZING)
  1686.             {
  1687.                this.setState(mx.video.VideoPlayer.LOADING);
  1688.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  1689.             }
  1690.          }
  1691.          else
  1692.          {
  1693.             this._pause(false);
  1694.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1695.          }
  1696.       }
  1697.       else
  1698.       {
  1699.          this.setState(mx.video.VideoPlayer.STOPPED);
  1700.       }
  1701.    }
  1702.    function _createStream()
  1703.    {
  1704.       this._ns = new NetStream(this._ncMgr.getNetConnection());
  1705.       this._ns.mc = this;
  1706.       if(this._ncMgr.isRTMP())
  1707.       {
  1708.          this._ns.onStatus = function(info)
  1709.          {
  1710.             this.mc.rtmpOnStatus(info);
  1711.          };
  1712.       }
  1713.       else
  1714.       {
  1715.          this._ns.onStatus = function(info)
  1716.          {
  1717.             this.mc.httpOnStatus(info);
  1718.          };
  1719.       }
  1720.       this._ns.onMetaData = function(info)
  1721.       {
  1722.          this.mc.onMetaData(info);
  1723.       };
  1724.       this._ns.onCuePoint = function(info)
  1725.       {
  1726.          this.mc.onCuePoint(info);
  1727.       };
  1728.       this._ns.setBufferTime(this._bufferTime);
  1729.    }
  1730.    function _setUpStream()
  1731.    {
  1732.       this._video.attachVideo(this._ns);
  1733.       this.attachAudio(this._ns);
  1734.       if(!isNaN(this._ncMgr.getStreamLength()) && this._ncMgr.getStreamLength() >= 0)
  1735.       {
  1736.          this._streamLength = this._ncMgr.getStreamLength();
  1737.       }
  1738.       if(!isNaN(this._ncMgr.getStreamWidth()) && this._ncMgr.getStreamWidth() >= 0)
  1739.       {
  1740.          this._videoWidth = this._ncMgr.getStreamWidth();
  1741.       }
  1742.       else
  1743.       {
  1744.          this._videoWidth = undefined;
  1745.       }
  1746.       if(!isNaN(this._ncMgr.getStreamHeight()) && this._ncMgr.getStreamHeight() >= 0)
  1747.       {
  1748.          this._videoHeight = this._ncMgr.getStreamHeight();
  1749.       }
  1750.       else
  1751.       {
  1752.          this._videoHeight = undefined;
  1753.       }
  1754.       if((this._autoSize || this._aspectRatio) && this._videoWidth != undefined && this._videoHeight != undefined)
  1755.       {
  1756.          this._prevVideoWidth = undefined;
  1757.          this._prevVideoHeight = undefined;
  1758.          this.doAutoResize();
  1759.       }
  1760.       if(!this._autoSize && !this._aspectRatio || this._videoWidth != undefined && this._videoHeight != undefined)
  1761.       {
  1762.          if(this._autoPlay)
  1763.          {
  1764.             if(!this._ncMgr.isRTMP())
  1765.             {
  1766.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1767.                this._play();
  1768.             }
  1769.             else if(this._isLive)
  1770.             {
  1771.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1772.                this._play(-1);
  1773.             }
  1774.             else
  1775.             {
  1776.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1777.                this._play(0);
  1778.             }
  1779.          }
  1780.          else
  1781.          {
  1782.             this._cachedState = mx.video.VideoPlayer.STOPPED;
  1783.             if(this._ncMgr.isRTMP())
  1784.             {
  1785.                this._play(0,0);
  1786.             }
  1787.             else
  1788.             {
  1789.                this._play();
  1790.                this._pause(true);
  1791.                this._seek(0);
  1792.             }
  1793.          }
  1794.       }
  1795.       else
  1796.       {
  1797.          if(!this._hiddenForResize)
  1798.          {
  1799.             this.__visible = this._visible;
  1800.             this._visible = false;
  1801.             this._volume = this._sound.getVolume();
  1802.             this._sound.setVolume(0);
  1803.             this._hiddenForResize = true;
  1804.          }
  1805.          this._hiddenForResizeMetadataDelay = 0;
  1806.          this._play(0);
  1807.          if(this._currentPos > 0)
  1808.          {
  1809.             this._seek(this._currentPos);
  1810.             this._currentPos = 0;
  1811.          }
  1812.       }
  1813.       clearInterval(this._autoResizeIntervalID);
  1814.       this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1815.    }
  1816.    function doIdleTimeout()
  1817.    {
  1818.       clearInterval(this._idleTimeoutIntervalID);
  1819.       this._idleTimeoutIntervalID = 0;
  1820.       this.close();
  1821.    }
  1822.    function flushQueuedCmds()
  1823.    {
  1824.       while(this._cmdQueue.length > 0)
  1825.       {
  1826.          this._cmdQueue.pop();
  1827.       }
  1828.    }
  1829.    function execQueuedCmds()
  1830.    {
  1831.       while(this._cmdQueue.length > 0 && (this.stateResponsive || this._state == mx.video.VideoPlayer.CONNECTION_ERROR) && (this._cmdQueue[0].url != null || this._state != mx.video.VideoPlayer.DISCONNECTED && this._state != mx.video.VideoPlayer.CONNECTION_ERROR))
  1832.       {
  1833.          var _loc2_ = this._cmdQueue.shift();
  1834.          this._cachedState = this._state;
  1835.          this._state = mx.video.VideoPlayer.EXEC_QUEUED_CMD;
  1836.          switch(_loc2_.type)
  1837.          {
  1838.             case mx.video.VideoPlayer.PLAY:
  1839.                this.play(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1840.                break;
  1841.             case mx.video.VideoPlayer.LOAD:
  1842.                this.load(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1843.                break;
  1844.             case mx.video.VideoPlayer.PAUSE:
  1845.                this.pause();
  1846.                break;
  1847.             case mx.video.VideoPlayer.STOP:
  1848.                this.stop();
  1849.                break;
  1850.             case mx.video.VideoPlayer.SEEK:
  1851.                this.seek(_loc2_.time);
  1852.                break;
  1853.          }
  1854.       }
  1855.    }
  1856.    function queueCmd(type, url, isLive, time)
  1857.    {
  1858.       this._cmdQueue.push({type:type,url:url,isLive:isLive,time:time});
  1859.    }
  1860. }
  1861.